<template>
  <viewer class="SxViewer" :images="images" :options="options" @inited="inited">
    <img v-for="(src, index) in images" :key="src + index" :src="src" />
  </viewer>
</template>

<script>
export default {
  name: 'SxViewer',
  props: {
    options: {
      type: Object
    }
  },
  data() {
    return {
      images: [],
      viewerNode: null
    }
  },
  methods: {
    inited(viewer) {
      this.viewerNode = viewer
    },
    update(images, index = 0) {
      this.viewerNode.index = index
      this.images = images instanceof Array ? images : [images]
      this.viewerNode.show()
    }
  }
}
</script>

<style scoped lang="scss">
.SxViewer {
  display: none;
}
</style>
